package com.ikun.admin.modules.auth.utils;


import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class DefaultPasswordEncoder implements PasswordEncoder {

    private static final String SING = "IKUN";

    public DefaultPasswordEncoder() {
        this(-1);
    }

    public DefaultPasswordEncoder(int strength) {
    }

    public static void main(String[] args) {
        System.out.println(new DefaultPasswordEncoder().encode("ikun666"));
    }

    @Override
    public String encode(CharSequence charSequence) {
        return MD5.encrypt(SING+charSequence.toString());
    }

    @Override
    public boolean matches(CharSequence charSequence, String passwordSelect) {
        String encryptPassword = encode(charSequence);
        if (encryptPassword.equals(passwordSelect)) {
            return true;
        }
        return false;
    }

}
